https://leetcode.cn/problems/minimum-time-to-revert-word-to-initial-state-i/description/


class Solution {
public:
    int minimumTimeToInitialState(string word, int k) {

        string str = "";
        for (int i = 0; i < k; i++)
            str += word[i];

        int cnt = 1;
        for (int i = k; i < word.size(); i += k)
        {
            int x = 0, y = 0;
            bool flag = true;
            for (int j = i; j < word.size(); j++)
            {
                if (x >= k)
                {
                    if (word[j] != word[x])
                        flag = false;
                }
                else
                {
                    if (word[j] != str[x])
                        flag = false;
                }
                x++;
            }
            if (!flag)
            {
                cnt++;
                // cout << " i: " << i;
            }
            else
                break;
        }
        return cnt;
    }
};
